package com.learncloud.common.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * <p>
 * <p>
 * <p/>
 *
 * @author : yj
 */
@Component
@ConfigurationProperties(prefix = "minio")
@Getter
@Setter
public class MinioConfigParams {

    private String endpoint;

    private String accessKey;

    private String secretKey;

    private String imgBucket;

    private String temporaryStorage;

    private String videoBucket;

    private String readOnlyPrefix;

    private String fragmentSize;

    private String localFilePrefix;



    public Long getFragmentSize(){
        String substring = fragmentSize.substring(fragmentSize.length() - 2, fragmentSize.length());
        Long size = Long.valueOf(fragmentSize.split(substring)[0]);
        if ("KB".equals(substring)){
            size = size * 1024;
        }else if ("MB".equals(substring)){
            size = size * 1024 * 1024;
        }else if ("GB".equals(substring)){
            size = size * 1024 * 1024 * 1024;
        }
        return size;
    }
}
